<?php get_header(); ?>
<?php get_sidebar(); ?>

<div id="primary">
    <div id="content" role="main">
        <?php if ( have_posts() ) while ( have_posts() ) : the_post(); global $_product; $_product = new jigoshop_product( $post->ID ); ?>
            <section id="product-id-1" class="product-single">
                <div id="product-images">
                    <div id="large-img">
                        <?php
                            $thumb_id = 0;
                            if (has_post_thumbnail()) :
                                $img = wp_get_attachment_image_src( get_post_thumbnail_id(), 'shop_large');
                                echo '<img src="' . $img[0] . '" />';
                            else :
                                    echo jigoshop_get_image_placeholder( 'shop_large' );
                            endif;
                        ?>
                    </div>
                    <?php jigoshop_show_product_thumbnails_customize(); ?>
                </div>
                <div id="product-info">
                        <h3 class="title"><?php the_title(); ?></h3>
                        <span class="st_fblike_hcount"></span>
                        <span class="st_twitter_hcount"></span>
                        <span class="st_plusone_hcount"></span>
                        <span class="st_sharethis_hcount"></span>
                            <p class="price"><?php echo $_product->get_price_html(); ?></p>
                        <p class="meta">
                        <?php if ( comments_open() ) : ?><a href="#reviews"><?php echo comments_number('0 ', '1 ', '% '); ?><?php _e('Reviews', 'jigoshop'); ?></a><?php endif; ?>
                        <?php edit_post_link( __( 'Edit', 'kawaii' ), ' | <span class="edit-link">', '</span>' ); ?>
                        </p>
                        <?php echo $_product->get_tags( ', ', ' <div class="tagged_as">' . __( 'Tagged as ', 'jigoshop' ) . '', '.</div>'); ?></p>
                        <p class="help">
                            <?php if ( $_product->is_type( 'simple' ) ) : ?>
                                <?php _e( 'Số lượng muốn đặt hàng', 'jigoshop' ); ?>
                            <?php else : ?>
                                <?php _e( 'Vui lòng chọn kích cỡ, màu sắc sản phẩm', 'jigoshop' ); ?>
                            <?php endif; ?>
                        </p>
                        <div class="buy-option">
                            <?php if ( $_product->is_in_stock() ) {
                                do_action( $_product->product_type . '_add_to_cart' );
                            } ?>
                        </div>
                </div>
            </section>
            <?php 
                $is_single_product = true; 
                if (get_option ('jigoshop_enable_related_products') != 'no') : ?>
            <section class="related-product">
                <div id="products-list" class="products-grid"><?php
                    global $_product, $columns, $per_page;
        
            		// Pass vars to loop
            		$per_page = 4;
            		$columns = 4;
            
            		$related = $_product->get_related( 4 );
            		if (sizeof($related)>0) :
            			echo '<h2>'.__('Related Products', 'jigoshop').'</h2>';
            			$args = array(
            				'post_type'	=> 'product',
            				'ignore_sticky_posts'	=> 1,
            				'posts_per_page' => $per_page,
            				'orderby' => 'rand',
            				'post__in' => $related
            			);
            			$args = apply_filters('jigoshop_related_products_args', $args);
            			query_posts($args);
            			jigoshop_get_template_part( 'loop', 'shop' );
            			wp_reset_query();
            		endif;
            		$per_page = null;   // reset for cross sells if enabled
            		$columns = null; ?>
        		</div>
            </section>
            <?php endif; ?>
            <section id="reviews">
                <?php comments_template(); ?>
            </section>
        <?php endwhile; ?>
    </div><!-- #content -->
</div><!-- #primary -->

<?php get_footer(); ?>